package com.itheima.flow;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;


public class FlowMapperTask extends Mapper<LongWritable, Text, Text,FlowPojo> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line = value.toString();
        if(line!=null & !"".equals(line)){
            String[] split = line.split("\t");
            FlowPojo flowPojo = new FlowPojo();
            flowPojo.setUpPackNum(Long.parseLong(split[6]));
            flowPojo.setDownPackNum(Long.parseLong(split[7]));
            flowPojo.setUpPayLoad(Long.parseLong(split[8]));
            flowPojo.setDownPayLoad(Long.parseLong(split[9]));

            context.write(new Text(split[1]),flowPojo);
        }
    }
}
